<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>PostMessage Children</title>
  </head>
  <body>
    <h2>Children</h2>
    <button id="btn">发送消息</button>
    <script>
      document.getElementById("btn").addEventListener("click", () => {
        window.parent.postMessage("您好，我是您儿子：", "*");
      });
      window.addEventListener("message", (event) => {
        console.log("爸爸的消息：", event.data);
      });
    </script>
  </body>
</html>
